package com.tyut.controller;

import com.tyut.pojo.Result;
import com.tyut.service.EditorService;
import com.tyut.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin")
public class AdminController {
	@Autowired
	private UserService userService;
	@Autowired
	private EditorService editorService;
	@PutMapping("/user")
	public Result updateUserState(Integer id,String state){
		state = state.equals("1") ? "0" : "1";
		userService.updateState(id,state);
		return Result.success();
	}

	@PutMapping("/editor")
	public Result updateEditorState(Integer id,String state){
		state = state.equals("1") ? "0" : "1";
		editorService.updateState(id,state);
		return Result.success();
	}
	@DeleteMapping("/editor")
	public Result deleteEditor(Integer id){
		editorService.delete(id);
		return Result.success("删除编辑成功");
	}

}
